package com.deram.ctin.serv.enter.impl;

import com.deram.ctin.common.bean.PageResult;
import com.deram.ctin.common.utils.DateUtils;
import com.deram.ctin.serv.enter.api.EnterInfoApi;
import com.deram.ctin.serv.enter.entity.BaseUpdateInfo;
import com.deram.ctin.serv.enter.entity.EnterInfo;
import com.deram.ctin.serv.enter.filter.EnterInfoFilter;
import com.deram.ctin.serv.enter.service.EnterInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: jtt
 * @Description:
 * @Date: 2017/9/12 10:21
 * @version: V1.0
 */
@RestController
public class EnterInfoApiImpl implements EnterInfoApi {

    private static final Logger logger = LoggerFactory.getLogger(EnterInfoApiImpl.class);

    @Autowired
    private EnterInfoService enterInfoService;

    @Override
    public EnterInfo findById(Long id) {
        return enterInfoService.find(id);
    }

    @Override
    public List<EnterInfo> searchByKeywords(String keywords) {
        return enterInfoService.searchByKey(keywords);
    }

    @Override
    public List<EnterInfo> searchByFather(@RequestParam("fatherId") Long fatherId) {
        return enterInfoService.searchByFather(fatherId);
    }

    @Override
    public List<EnterInfo> list(@RequestBody EnterInfoFilter filter) {
        return enterInfoService.list(filter);
    }

    @Override
    public PageResult<EnterInfo> search(@RequestBody EnterInfoFilter filter, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) {
        return enterInfoService.findByFather(filter, pageNo, pageSize);
    }

    @Override
    public EnterInfo save(@RequestBody EnterInfo param) {
        return enterInfoService.save(param);
    }

    @Override
    public void insertList(@RequestBody BaseUpdateInfo<EnterInfo> param) {
        enterInfoService.insertList(param.getList());
    }

    @Override
    public void delete(Long id) {
        enterInfoService.delete(id);
    }

    @Override
    public List<EnterInfo> findAll() {
        return enterInfoService.findAll();
    }
}
